﻿<UserControl x:Class="Peter.Sdw.View.SdwMainView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:logic="clr-namespace:Peter.Sdw.Logic"
             xmlns:controls="clr-namespace:Peter.Common.Controls;assembly=Peter.Common"
             xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300"
             d:DataContext="{d:DesignInstance logic:SdwMainModel}">
   <Grid>
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto" />
         <RowDefinition Height="*" />
      </Grid.RowDefinitions>
      
      <Button Grid.Row="0"
              Command="{Binding Path=LoginCommand}"
              Visibility="{Binding Path=IsLoginVisible, Converter={StaticResource _BoolToVisi}}">
         <StackPanel Orientation="Horizontal">
            <icons:IconDisplay Icon="User"
                               IconSize="MediumLarge" />
            <TextBlock Text="Login"
                       Margin="4,0,0,0" />
         </StackPanel>
      </Button>
      
      <Grid Grid.Row="1">
         <Grid.RowDefinitions>
            <RowDefinition Height="*" />
         </Grid.RowDefinitions>
         <Grid Grid.Row="0">
            <Grid.RowDefinitions>
               <RowDefinition Height="*" />
               <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <ListBox Grid.Row="0"
                     controls:Ex.ExecuteCommand="{Binding Path=EditLightCommand}"
                     SelectedValue="{Binding Path=SelectedLight}"
                     ItemsSource="{Binding Path=Lights}">
               <ListBox.ItemTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Path=Name}" />
                  </DataTemplate>
               </ListBox.ItemTemplate>
            </ListBox>
            
            <Grid Grid.Row="1">
               <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="*" />
               </Grid.ColumnDefinitions>

               <Button Grid.Column="0"
                       CommandParameter="prev"
                       ToolTip="Previous Results"
                       Command="{Binding Path=NavigateListCommand}">
                  <icons:IconDisplay Icon="Previous" />
               </Button>

               <Button Grid.Column="1"
                       ToolTip="Refresh the list of books"
                       Command="{Binding Path=RefreshCommand}">
                  <icons:IconDisplay Icon="Refresh" />
               </Button>

               <Button Grid.Column="2"
                       ToolTip="Add a new Book"
                       Command="{Binding Path=AddLightCommand}">
                  <icons:IconDisplay Icon="Createfile" />
               </Button>

               <Button Grid.Column="3"
                       ToolTip="Next Results"
                       CommandParameter="next"
                       Command="{Binding Path=NavigateListCommand}">
                  <icons:IconDisplay Icon="Next" />
               </Button>
               
            </Grid>

            <Border Grid.Row="0"
                    Grid.RowSpan="2"
                    Height="75"
                    Width="150"
                    CornerRadius="5"
                    Background="SteelBlue"
                    Visibility="{Binding Path=IsLoading, Converter={StaticResource _BoolToVisi}}">
               <TextBlock Text="Loading..."
                          FontSize="16"
                          Foreground="White"
                          FontStyle="Italic"
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center" />
            </Border>
         </Grid>
         </Grid>
   </Grid>
</UserControl>
